#include <bits/stdc++.h>
using namespace std;

struct TreeNode
{
    int val;
    struct TreeNode *left;
    struct TreeNode *right;
    TreeNode(int x) : val(x), left(nullptr), right(nullptr)
    {
    }
};

class Solution
{
  public:
    TreeNode *Mirror(TreeNode *pRoot)
    {
        if (pRoot == nullptr)
        {
            return nullptr;
        }
        swap(pRoot->left, pRoot->right);
        pRoot->left = Mirror(pRoot->left);
        pRoot->right = Mirror(pRoot->right);
        return pRoot;
    }
};
